home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / amusemen / nolan-1.1 / nolan.tar / compilescript next >
Text File  |  1994-04-25  |  2KB  |  91 lines

  1. #
  2. # This script generates C code from its input, which is presumed to be in the
  3. # baby script language documented for the purpose.  This code then gets
  4. # included in nolan.c to become the actual script program
  5. #
  6. sed <nolan.script \
  7.     -e '1,$s/\\[^n]/\\&/g' \
  8.     -e '1,$s/"/\\"/g' \
  9. | awk '
  10. BEGIN        {nroutines = 0;}
  11. /^@action /    {printf("    %s", substr($0, 9)); next;}
  12. /^@before /    {
  13.             printf("    if (found > 1)\n");
  14.             printf("    display(\"%s\\n\");\n", substr($0, 9));
  15.             printf("    else\n");
  16.             printf("    display(\"\\n\");\n");
  17.             next;
  18.         }
  19. /^@center /    {
  20.             text = substr($0, 8);
  21.  
  22.             printf("    movecursor(row, CENTER(\"%s\"));\n", text);
  23.             printf("    display(\"%s\\n\");\n", text);
  24.             next;
  25.         }
  26. /^@diamond/    {
  27.             print "    down = DOWN(economic, personal);"
  28.             print "    scatter[personal][economic]++;"
  29.             next;
  30.             }
  31. /^@dispatch/    {exitready = 2; next;}
  32. /^@endscreen/    {
  33.             if (exitready == 0)
  34.                 printf("    return(screenend(NEXT, %s));\n",$2);
  35.             else if (exitready == 1)
  36.                 print "    return(screenend(EXIT, NULL));";
  37.             else
  38.                 print "    return(screenend(dispatch(),NULL));";
  39.             print "}"
  40.             screennum++;
  41.             next;
  42.         }
  43. /^@exitprompt/    {exitready = 1; next;}
  44. /^@exit\$/    {printf("    return(EXIT);\n"); next;}
  45. /^@scattergram/    {printf("    scattergram();\n"); next;}
  46. /^@screen/    {
  47.             printf("\nstatic int %s()\n{\n",$2);
  48.             printf("    down=-1; score = nquestions = row = 0;\n");
  49.             printf("    clearscreen();\n");
  50.             exitready = linecnt = 0;
  51.             routines[nroutines++] = $2;
  52.             next;
  53.         }
  54. /^@standout{/    {
  55.             printf("#define STANDOUT    \"%s\"\n", substr($0, 11, 1));
  56.             next;
  57.         }
  58. /^@authoritarian/    {
  59.                 printf("#define AUT_SCREEN %d\n", screennum);
  60.                 next;
  61.             }
  62. /^@conservative/    {
  63.                 printf("#define CON_SCREEN %d\n", screennum);
  64.                 next;
  65.             }
  66. /^@centrist/        {
  67.                 printf("#define CEN_SCREEN %d\n", screennum);
  68.                 next;
  69.             }
  70. /^@left-liberal/    {
  71.                 printf("#define LEF_SCREEN %d\n", screennum);
  72.                 next;
  73.             }
  74. /^@libertarian/        {
  75.                 printf("#define LIB_SCREEN %d\n", screennum);
  76.                 next;
  77.             }
  78.  
  79.         {
  80.                 printf("    display(\"%s\\n\");\n", $0);
  81.         }
  82. END        {
  83.             print "\nstatic intfunc    screenfuncs[] = {"
  84.             for (i = 0; i < nroutines; i++)
  85.                 printf("    %s,\n", routines[i]);
  86.             print "    (intfunc)NULL"
  87.             print "};"
  88.         }
  89. '
  90.  
  91.